export {
  setGeojson,
  flyTo,
  addWMTSLayer,
  removeLayer
}

//加载geojson
const setGeojson = (map, json, style) => {
  let layer = L.geoJSON(json).setStyle(style).addTo(map)
  return layer
}

//飞行定位
const flyTo = (map,lon,lat, zoom) => {
  zoom = zoom ?? 16
  map.flyTo([lat, lon], zoom);
}

//加载wmts图层
const addWMTSLayer = (map,url,index = 3) => {
  const layer = new L.TileLayer(url, { tileSize: 512 });
  map.addLayer(layer);
  layer.setZIndex(index);
  return layer
}

 //移除图层
const  removeLayer = (map,layer) =>{
  if (layer) {
    map.removeLayer(layer);
  }
}

